package com.hst.capacity.facade.rest;

import com.hst.capacity.application.biz.RegionBiz;
import com.hst.capacity.domain.exception.BusinessException;
import com.hst.capacity.domain.model.request.franchisee.FranchiseeParam;
import com.hst.capacity.domain.model.response.DefaultVO;
import com.hst.capacity.infra.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;

import static com.hst.capacity.domain.model.response.DefaultVO.success;

/**
 *  基础设定模块Controller
 *
 * */
@RequestMapping("/region")
@RestController
public class RegionController {

    @Autowired
    private RegionBiz regionBiz;

    /**
     * 省市地区下拉框数据取得
     * @param
     * @return
     */
    @PostMapping("/lst")
    private DefaultVO getAllRegionList(){
        return success(regionBiz.getAllRegionList());
    }

    /**
     * 省市地区下拉框数据取得
     * @param
     * @return
     */
    @PostMapping("/lst/citycode")
    private DefaultVO getRegionList(@RequestBody Map<String,String> param){
        String citycode = param.get("citycode");
        if (StringUtil.isBlank(citycode))
            throw  new BusinessException(4001,"城市代码[citycode]不能为空");
        return success(regionBiz.getRegionList(citycode));
    }

    /**
     * 城市线路范围限定数据取得
     * @param
     * @return
     */
    @PostMapping("/lst/cityLine/scope")
    private DefaultVO getCityLineScopeList(@RequestBody Map<String,String> param){
        String cityCode = param.get("cityCode");
        if (StringUtil.isBlank(cityCode))
            throw  new BusinessException(4001,"城市代码[cityCode]不能为空");
        return success(regionBiz.getCityLineScopeList(cityCode));
    }

}
